//************************************************************
//    > File Name: qsrot.c
//    > Author: davis
//    > Mail:  
//    > Created Time: 2017年03月 8日 14:47:46
//***********************************************************

#include<stdio.h>
void qsort(int *a,int left,int right)
{
	if(left >= right)
		return;
	int first = left;
	int last = right;
	int key = a[left];
	while(first < last)
	{
		while(first<last && a[last]>=key)
			--last;
		a[first]=a[last];
		while(first<last && a[first]<=key)
			++first;
		a[last]=a[first];
	}
	a[first]=key;
	qsort(a,left,first-1);
	qsort(a,first+1,right);
}
void main()
{
	int a[]={3,1,2,5,4};
	for(int i=0;i<5;i++)
		printf("%d ",a[i]);
	printf("\n");
	qsort(a,0,sizeof(a)/sizeof(a[0])-1);
	for(int i=0;i<5;i++)
		printf("%d ",a[i]);
}
